package com.dzu.easy;

/**
 * @author ZhaoDong
 * @date 2022/11/8 9:52
 * @description 342. 4的幂
 */
public class Test342 {
    public static void main(String[] args) {
        System.out.println(isPowerOfFour(16));
    }

    public static boolean isPowerOfFour2(int n) {
        return n > 0 && (n & (n - 1)) == 0 && (n & 0b1010101010101010101010101010101) == n;
    }
    public static boolean isPowerOfFour(int n) {
        if (n < 1) {
            return false;
        }
        while (n % 4 == 0) {
            n /= 4;
        }
        return n == 1;
    }
}
